/*
 * @Author: xiaosihan
 * @Date: 2023-08-11 01:17:36
 * @Last Modified by: xiaosihan
 * @Last Modified time: 2024-05-05 04:06:50
 */

import { fabric } from 'fabric';

// 框选对象
export default class FabricActiveSelection extends fabric.ActiveSelection {
  constructor(
    objects?: fabric.Object[],
    options?: fabric.IObjectOptions,
  ) {
    super(objects, options);

    const scaleWidth = this.getScaledWidth();
    const scaleHeight = this.getScaledHeight();
    this.left = (this.left || 0) + (scaleWidth / 2);
    this.top = (this.top || 0) + (scaleHeight / 2);

  }

  declare _element: any;
  declare _filterScalingX: any;
  declare _filterScalingY: any;

  declare id: string;

  declare src: string;

  declare name: string;

  // declare canvas?: FabricCanvas;

  centeredRotation = true;

  originX = 'center';

  originY = 'center';

  objectCaching = true;

  // 缩小时不翻转
  lockScalingFlip = true;

  //是否是打印模式,  打印模式会处理边缘羽化的问题, 只有在导出生产文件的时候才会,设置为true
  print = false;
}

fabric.ActiveSelection = FabricActiveSelection;
